-
Notifications
You must be signed in to change notification settings - Fork 88
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
KBS: combine CoCo Token and Jwk Token verifier #524
KBS: combine CoCo Token and Jwk Token verifier #524
Conversation
34bc38c
to
47002cd
Compare
47002cd
to
3d973d9
Compare
Good good good. |
This PR also changes some logic of previous JWK of CoCoAS, so ptal @jialez0 |
3d973d9
to
8c27e4f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Wdyt @mythi
My earlier comment in the original PR was that my preference is to not expose "ITA" as a token type to the user and that seems to be in this PR still. I was wondering whether we could just ask users to provide the list of trust anchors and try to parse the provided The only reason for "token type" to still exist seems to be the |
Yes. This PR supports the original ITA way, s.t. provode Another option is
Nice suggestion. The pro is flexibility while the con is extra complexity to remember the paths. I personally prefer the "token type" way as the user only needs to care about token type rather than claims inside that. I think you are caring about the name |
I was not very clear earlier. My comment was that can we have just one config entry. It would be easier for the user. It should be possible to handle
True, OTOH, we can always make known paths as the default and only provide the mechanism to add supplemental paths. |
Would it be OK to aim fixing #519 with PR too? |
Probably not. Currently it is hard for KBS to detect the JWT type (CoCoAS/ITA or else) runtimely. See #519 (comment) |
Do you mean that we have two config items
|
Could
Just one because |
Yes it can and it is implemented in this PR. What #519 aims is to support different public key claim path.
Ok. Could you provide an example for this in your mind? |
Right, sorry. I had missed that and got side tracked when you wrote that JWT detection cannot be done easily.
Instead of |
8f2d7af
to
2e9d713
Compare
Actually, the ITA token and CoCo Token are both JWTs. They both need a JWK to verify the JWT. The difference is the way to gather the JWK. This commit combined the two logic, and add two ways to get the JWK. 1. From the configured JwkSet when launching KBS 2. From the JWT's Header's jwk field. The two ways will check the jwk endorsement in different ways. The first way is to configure the trusted JwkSet from the config. The second way is to configure the trusted CA in config. Then get the public key cert chain from Jwk's x5c field. The both ways are also supported in this patch. Rust does not provide a mature crate to verify cert chain, thus openssl is used in this patch. We also abondon rustls and openssl feature of KBS because openssl is by default used. Then we use openssl by default to make the code base simpler. Signed-off-by: Xynnn007 <[email protected]>
Due to RFC 7515, JWK should be part of a JOSE Header rather than claim body. Signed-off-by: Xynnn007 <[email protected]>
2e9d713
to
2756ca3
Compare
@mythi Adds the change that you suggested. I think it is good to have some internal defined paths together with user defined extra paths. |
thanks! I personally feel it's better this way and I guess this now meets #519 also. My remaining concern is whether we need separate user facing config entries for |
Well as they are different things. One is jwkset and the other is root pem certs |
extra_teekey_paths: vec![], | ||
trusted_certs_paths: vec![], | ||
trusted_jwk_sets: vec![config.certs_file.clone()], | ||
insecure_key: true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
insecure_key: true, | |
insecure_key: false, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let me fix this. Btw, do you think we need to rename certs_file
to jwkset
or something else?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mythi Ok. Let me response here. Actually for ITA the configure item here both are ok as it will not change the behavior.
When I re-read the part of code, I have a question whether we need token_verifier
object here inside ITA backend plugin code. I am afraid that we do not.
The logic here is
- a user requests ITA for a token (and we do not need to care about the token trustiworthy as we just call the API of ITA)
- the user request KBS for resource (this time we should check the token trustiworthy)
wdyt?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had thought about the same but decided to keep it for now. We may have future feature additions like the faithful verification that further checks the token and it might be useful to do it here.
If the take this path, we might need a third one for "OpenID Configuration endpoints" which is what the default ITA config prefers. But my point was that some generic config entry would probably keep things simple for the users. |
Well. There are actually three items as you said
The 1 and 2 are in good design currently I think, by Before this patch the config item |
FWIW, ITA documentation calls these certificates: "To verify the token signature, first download the Intel Trust Authority signing certificates from the portal. " and that's why I though reusing Would there be any better name describing both root certs and jwksets? |
Well, it is somehow tricky. The things download from "https://portal.trustauthority.intel.com/certs" are actually public keys with its like {
"alg": "PS384",
"e": "AQAB",
"kid": "c68e5a7b3aec51a3ff384fe30799d465d55b16d57ef88d05f6067559d9156cd3d5302f89fe665d1fb9a6be4602be11d8",
"kty": "RSA",
"n": "yE07D7FRSXLsswdeK7h22kw-Xv2K2r4NFoefWElZ6FWmLvCcd27wGEczNeKrE91SWczPtR279tTasQN6_v8qsswC5rCGYlrRWvE0vuPoUXezlV4PX0tCJJJmxWtXFXW0dChWvR1j-_viOItfR8jrybV2-DyVBgGX1ad4BLJJseglPXcofhnKYcG9gp8J2zPFqs1tu6jTW-He3Xw7ZeQNq0n4ZfrRBM3GEYVVsWGlTlqVidMhbvMXSQgz1x2QjyPC2mSUrT-JyA2xTm84Mv_Lmz6FpHXsjXMyPKCUVUf8LSTAiw3UsHa-7QGUW51hh9lZsbWkdSfwGUGxjrcMNEwYo3KvcF8f9Cv1_bkla396poQhtTIHuV478PobzsCfdkbCF5CfwZN31KbqyD9o9pVyzmmQUmOikIZuiSPRnfIU_P8duM5F6yvxQPITZf1RhOPBNYLiOJge7C89OmsM46UKtAYNTieBH-J8oWUUWfAX3pO38bKIzNwHDelSbaeHterJ",
"x5c": [
"MIIE/DCCA2SgAwIBAgIBAjANBgkqhkiG9w0BAQ0FADBlMQswCQYDVQQGEwJVUzELMAkGA1UECAwCQ0ExGjAYBgNVBAoMEUludGVsIENvcnBvcmF0aW9uMS0wKwYDVQQDDCRJbnRlbCBUcnVzdCBBdXRob3JpdHkgQVRTIFNpZ25pbmcgQ0EwHhcNMjQwOTA5MTAzMzQ3WhcNMjUwOTA5MTAzMzQ3WjBwMQswCQYDVQQGEwJVUzELMAkGA1UECAwCQ0ExGjAYBgNVBAoMEUludGVsIENvcnBvcmF0aW9uMTgwNgYDVQQDDC9JbnRlbCBUcnVzdCBBdXRob3JpdHkgQXR0ZXN0YXRpb24gVG9rZW4gU2lnbmluZzCCAaIwDQYJ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X9oJ6b3mDWj3NQNBomBI8fq0hRgz9hKF8wpFpU3UzXtyBLLL18BTCQeJecb6pwrpASVZNmR/fAv8fbR9wWdTBVFHmIrg1wvU1u2WqYSdAgQGke+WdWFIvZCKKMVAB0jX2kPHBQnAkLF3pRaVyNT4I2MCRB8cW2fbSCIARBeryiIHyGCKnDGkDK+dvPxMJ9eMidPbBQBp5t6jxoicg9X8Gw9MeOboOEOB1sIAd0S25V9fzIwwn6j61K4d2VkLf4ZnDa2VKTgmv6NFMynu+JlHVYhQ0yin+dfD63XJvBLcfLrJwK10lsVMX7xv3dB4P+DBYHtWPwrjE28j6+IjCIupuarzDcahBTbRZIAAW4eWKrA3MPQVyGikcdnciFN7kL12EtHhrSBL2jTzsScWvatPqqzIeNxDCywNEyjtGYLnLBnZnbSP"
]
} But what we want to set
The two things also work differently in code. The former one will be used to look up jwk by given |
I agree that their content is very different. My only comment has been that for the user they are still both "token verification collateral" which is why I also asked:
If other reviewers think making them separate config entries is the right thing to do, I can live with that. |
…ugins This is just a hack to be able to test the nebula_ca plugin. $ cd kbs && make cli ATTESTER=snp-attester && make install-cli $ docker compose up $ kbs-client config --auth-private-key kbs/config/private.key set-resource-policy --policy-file kbs/sample_policies/allow_all.rego $ kbs-client get-resource --plugin-name "nebula_ca" --resource-path "credential?ip[ip]=10.9.8.2&ip[netbits]=21&name=podA" Currently, the last command is failing reporting Error: request unauthorized and in the trustee log: ERROR kbs::error] TokenVerifierError(TokenVerificationFailed { source: Cannot verify token since trusted JWK Set is empty }) I did not get to the bottom of the problem yet, but I think I may need the PR confidential-containers#524 as well
2756ca3
to
edad780
Compare
To make it clear. The current token verifier config looks like ...
[attestation_token_config]
# Path of root certificate used to verify the trustworthy of `x5c` extension in the JWT
# Defaults to empty
trusted_certs_paths = ["/path/to/trusted_cacert.pem"]
# URL (`path://` or `https://`) of the trusted JWK that can be indexed by `kid` in
# JWT Header.
# Defaults to empty
trusted_jwk_sets = ["/url/to/trusted_jwk_set"]
# Each JWT contains a TEE Public Key. Users can use the `extra_teekey_paths` field to additionally specify the path of this Key in the JWT.
# Example of `extra_teekey_paths` is `/attester_runtime_data/tee-pubkey` which refers to the key
# `attester_runtime_data.tee-pubkey` inside the JWT body claims. By default CoCo AS Token and Intel TA
# Token TEE Public Key paths are supported.
# Defaults to empty
extra_teekey_paths = [""]
# For Attestation Services like CoCo-AS, the public key to verify the JWT will be given
# in the token's `jwk` field (with or without the public key cert chain `x5c`).
#
# - If this flag is set to `true`, KBS will ignore to verify the trustworthy of the `jwk`.
# - If this flag is set to `false`, KBS will look up its `trusted_certs_paths` and the `x5c`
# field to verify the trustworthy of the `jwk`.
# Defaults to `false`
insecure_key = false |
Due to latest change, KBS will not maintain both rustls and openssl suites for HTTPS. Thus we need to delete all the options of HTTPS_CRYPTO config in documents and codes. Also, the latest change changes the config format of `attestation_token_config`, this patch also applies the change. Signed-off-by: Xynnn007 <[email protected]>
edad780
to
eadfd27
Compare
I see no real benefit in having fewer config entries, especially if doing so could cause confusion. If we are dealing with different types of stuff we might as well make different optional config entries and add some logic to make sure one of them is set. We can also tweak this down the road if we realize that it isn't ideal. |
I was mainly thinking user experience but ok. For some users it can be confusing that data downloaded from |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
This PR was not ready for merging. For example, you still have |
The configuration keeps the behavior same as before. Before this commit, the insecure key option is always true logically although there is not such a config item. I think we can fix this in future PR. |
This was not the case for |
Well. For old JWK (what ITA uses), the The docs upon
This is partially why two config items seem better to me during our previous conversion. |
Fair enough, the functionality seems fine. My original comment was related to unresolved conversations that were not addressed. |
This patch is part of #514.
ITA token and CoCo Token are both JWTs. They both need a JWK to verify the JWT. The difference is the way to gather the JWK.
This commit combined the two logic, and add two ways to get the JWK.
The two ways will check the jwk endorsement in different ways. The first way is to configure the trusted JwkSet from the config. The second way is to configure the trusted CA in config. Then get the public key cert chain from Jwk's x5c field. The both ways are also supported in this patch.
The difference between CoCo Token and ITA Token are where Tee Public key is embedded inside the token, this could be configured in the launch toml of KBS, because it is hard to detect during runtime.
Rust does not provide a mature crate to verify cert chain, thus openssl is used in this patch. We also abondon rustls and openssl feature of KBS because openssl is by default used. Then we use openssl by default to make the code base simpler.
Close #486
cc @mythi